package edu.pku.sei.transformation.atl.adapter;

import java.util.ArrayList;
import java.util.List;

import edu.pku.sei.transformation.atl.rule.IATLHeader;
import edu.pku.sei.transformation.atl.rule.IATLModel;
import edu.pku.sei.transformation.editor.model.TypedModel;
import edu.pku.sei.transformation.editor.model.execution.TransformationExecution;

public class ATLHeaderAdapter implements IATLHeader {
	TransformationExecution transExe = null;

	ATLHeaderAdapter(TransformationExecution execution) {
		this.transExe = execution;
	}

	@Override
	public String getName() {
		return this.transExe.getTransformation().getName();
	}

	@Override
	public List<IATLModel> getSources() {
		ArrayList<IATLModel> models = new ArrayList<IATLModel>();
		ArrayList<TypedModel> typedModels = new ArrayList<TypedModel>();
		typedModels.addAll(transExe.getTransformation().getTypedModel());
		typedModels.remove(transExe.getDirection());
		for (TypedModel typedModel : typedModels) {
			models.add(new ATLModelAdapter(typedModel));
		}
		return models;
	}

	@Override
	public List<IATLModel> getTargets() {
		ArrayList<IATLModel> models = new ArrayList<IATLModel>();
		models.add(new ATLModelAdapter(transExe.getDirection()));
		return models;
	}

	@Override
	public boolean isRefine() {
		return false;
	}

}
